#!/bin/sh
. $HOME/.config/defaultprograms.txt

case "$1" in
 -default)
 echo $TEXTEDITOR > $HOME/.config/tmp/editor
 
 programchooser $TEXTEDITOR accessories-text-editor Development None > $HOME/.config/tmp/texteditor
 cat $HOME/.config/defaultprograms.txt | grep -v TEXTEDITOR > $HOME/.config/defaultprograms.new
 TEXTEDITOR="`cat $HOME/.config/tmp/texteditor`"
 [ "$TEXTEDITOR" = "" ] && TEXTEDITOR="cat $HOME/.config/tmp/editor"
 echo TEXTEDITOR=\"$TEXTEDITOR\" >> $HOME/.config/defaultprograms.new
 mv -f $HOME/.config/defaultprograms.new $HOME/.config/defaultprograms.txt
 #rm -f $HOME/.config/tmp/editor
 #rm -f $HOME/.config/tmp/texteditor
 ;;
 *)
 defaulttexteditor "$@"
 ;;
esac
